// 全局混入

import { mapMutations } from "vuex";

import { call } from "@/api/customer";
import { MessageBox } from "element-ui";

export default {
  methods: {
    ...mapMutations("app", ["setLoading"]),
    showAppLoading() {
      this.setLoading({ loading: true });
    },
    hideAppLoading() {
      this.setLoading({ loading: false });
    },
    async callPhone(item) {
      let _this = this;
      const { id, mobile } = item;
      const parmas = {
        customerId: id,
        mobile,
      };
      const res = await call(parmas);
      if (!res.result) return;
      MessageBox.confirm(res.message, "提示", {
        confirmButtonText: "已拨通",
        cancelButtonText: "取消",
        type: "success",
      }).then(() => {});
      _this.timer = setTimeout(function () {
        MessageBox.close();
      }, 6000);
    },

    // 字段截取
    cutWordLength(str,num){
      if (!str) {
        return ''
      }
  
      let m = 10
      let n = str
      if (num) {
        m = num
      }
      if (str.length > m) {
        n = str.slice(0, m) + '...'
      }
  
      return n
    }

  },
};
